/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			uvarbool.h
  \date			Dec 2011
  \author		TNick

  \brief		Contains the definition for UVarBool class


*//*


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read COPYING and README files in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __UVARBOOL_INC__
#define __UVARBOOL_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<uservar.h>
#include	<defvar.h>


/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

namespace	PgScr	{

class	UVarBool	: public DefVar	{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

public:

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

public:

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */



public:

	/// constructor
	UVarBool				( void );


	/// destructor;
	virtual				~UVarBool			( void );


	/**
	* @brief get a string representation of the object / variable
	*/
	QString		presentation	( VarStore * uv = NULL );


	/**
	* @brief resetContent resets the variable and frees any resources
	*/
	void		resetContent	( VarStore * uv = NULL )
	{ uv->l = 0; }


	/**
	* @brief set default value
	*/
	void				setDefault		( VarStore * uv = NULL );


	/**
	*	@brief	describes in a short string the type of undelying storage
	*
	*/
	QString				typeName		( VarStore * uv = NULL )
	{ Q_UNUSED( uv ); return "bool"; }


	/** @name Retrieving common values
	*
	*/
	//@{

	bool				convToBool		( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return uv->b; }

	qint16				convToShort		( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return ( uv->b ? 1 : 0 ); }

	qint32				convToInt		( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return ( uv->b ? 1 : 0 ); }

	qint64				convToLong		( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return ( uv->b ? 1 : 0 ); }

	qint8				convToByte		( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return ( uv->b ? 1 : 0 ); }

	qreal				convToDouble	( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return ( uv->b ? 1.0 : 0.0 ); }

	QStringList			convToStrLst	( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return QStringList( ( uv->b ? "true" : "false" ) ); }

	QString				convToStr		( bool * b_ok, VarStore * uv = NULL )
	{ *b_ok = true; return QString( ( uv->b ? "true" : "false" ) ); }

	//@}

	/**
	*	@brief	tell if this type of variable may be saved (is saveable)
	*
	*	@return	true if variable can be saved, false otherwise
	*/
	bool				canSave			( VarStore * uv = NULL )
	{ Q_UNUSED(uv); return true; }


	/**
	*	@brief	save the content of the variable
	*
	*	The variable is saved as a group at current path. The name of the
	*	group is given by the name of the variable and, inside, the type and
	*	actual value are saved using \b TAG_NAME_TYPE and \b TAG_NAME_VALUE.
	*
	*	@return	true if variable was saved, false otherwise

	*/
	bool				save			(
			PgSave::IPgSave &		stg,
			VarStore *				uv = NULL
			);


	/**
	*	@brief	load the content of the variable
	*
	*	The variable is saved as a group at current path. The name of the
	*	group is given by the name of the variable and, inside, the type and
	*	actual value are saved using \b TAG_NAME_TYPE and \b TAG_NAME_VALUE.
	*
	*	@return	true if variable was loaded, false otherwise
	*/
	bool				load			(
			PgSave::IPgSave &		stg,
			VarStore *				uv = NULL
			);


public:


	/**
	*	@brief	creates an variable of this type based on settings
	*/
	static bool			blindCreate		(
			PgSave::IPgSave *	intf,
			QString				s_path,
			void *				kb_data
			);



	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};

/*  CLASS    =============================================================== */
//
//
//
//

#ifdef	PGSCRIPT_TESTS
void				VarBool_Tests					(
		int & performed,
		int & succeded
		);
#endif

}	//	namespace	PlayGr

#endif // __UVARBOOL_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
